package org.example.controller;


import org.example.pojo.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Controller
public class Thymeleaf {

    @GetMapping("th/{param1}/{param2}")
    public String aa(Model model, @PathVariable("param1") int a,@PathVariable("param2") int b) {
        model.addAttribute("param1",a);
        model.addAttribute("param2",b);
        return "thym";
    }


    @GetMapping("/each")
    public String aaa(Model model) {
        List<Student> students = Arrays.asList(new Student("20240001","愚公",null),
                                               new Student("20240002","夸父",null),
                                               new Student("20240003","精卫",null));
        model.addAttribute("students",students);
        return "thym1";
    }


    @GetMapping("/obj/{param}")
    public String obj(@PathVariable("param") Double param, Model model){
        int value = (int)Math.ceil(param);
        model.addAttribute("data",value);
        return "obj";
    }
}
